#include <stdio.h>

void sum_rows(int va[3][4], int vb);
void sum_cols(int va[3][4], int vb);
int sum2d(int va[3][4], int vb);

int main()
{
 /*80484d0:	55                   	push   %ebp
 80484d1:	89 e5                	mov    %esp,%ebp
 80484d3:	83 e4 f0             	and    $0xfffffff0,%esp
 80484d6:	83 ec 40             	sub    $0x40,%esp
 80484d9:	c7 44 24 10 02 00 00 	movl   $0x2,0x10(%esp)
 80484e0:	00 
 80484e1:	c7 44 24 14 04 00 00 	movl   $0x4,0x14(%esp)
 80484e8:	00 
 80484e9:	c7 44 24 18 06 00 00 	movl   $0x6,0x18(%esp)
 80484f0:	00 
 80484f1:	c7 44 24 1c 08 00 00 	movl   $0x8,0x1c(%esp)
 80484f8:	00 
 80484f9:	c7 44 24 20 03 00 00 	movl   $0x3,0x20(%esp)
 8048500:	00 
 8048501:	c7 44 24 24 05 00 00 	movl   $0x5,0x24(%esp)
 8048508:	00 
 8048509:	c7 44 24 28 07 00 00 	movl   $0x7,0x28(%esp)
 8048510:	00 
 8048511:	c7 44 24 2c 09 00 00 	movl   $0x9,0x2c(%esp)
 8048518:	00 
 8048519:	c7 44 24 30 0c 00 00 	movl   $0xc,0x30(%esp)
 8048520:	00 
 8048521:	c7 44 24 34 0a 00 00 	movl   $0xa,0x34(%esp)
 8048528:	00 
 8048529:	c7 44 24 38 08 00 00 	movl   $0x8,0x38(%esp)
 8048530:	00 
 8048531:	c7 44 24 3c 06 00 00 	movl   $0x6,0x3c(%esp)
 8048538:	00 */
	int a[3][4] = {{2,4,6,8},{3,5,7,9},{12,10,8,6}};

 /*8048539:	c7 44 24 04 03 00 00 	movl   $0x3,0x4(%esp)
 8048540:	00 
 8048541:	8d 44 24 10          	lea    0x10(%esp),%eax
 8048545:	89 04 24             	mov    %eax,(%esp)
 8048548:	e8 3f 00 00 00       	call   804858c <sum_rows>*/
	sum_rows(a, 3);

 /*804854d:	c7 44 24 04 03 00 00 	movl   $0x3,0x4(%esp)
 8048554:	00 
 8048555:	8d 44 24 10          	lea    0x10(%esp),%eax
 8048559:	89 04 24             	mov    %eax,(%esp)
 804855c:	e8 92 00 00 00       	call   80485f3 <sum_cols> */
	sum_cols(a, 3);

 /*8048561:	c7 44 24 04 03 00 00 	movl   $0x3,0x4(%esp)
 8048568:	00 
 8048569:	8d 44 24 10          	lea    0x10(%esp),%eax
 804856d:	89 04 24             	mov    %eax,(%esp)
 8048570:	e8 e5 00 00 00       	call   804865a <sum2d>*/

 /*8048575:	89 44 24 04          	mov    %eax,0x4(%esp)
 8048579:	c7 04 24 44 87 04 08 	movl   $0x8048744,(%esp)
 8048580:	e8 0b fe ff ff       	call   8048390 <printf@plt>*/
	printf("%d\n", sum2d(a, 3));

 /*8048585:	b8 00 00 00 00       	mov    $0x0,%eax
 804858a:	c9                   	leave  
 804858b:	c3                   	ret    */
	return 0;
}

void sum_rows(int va[3][4], int vb)
{
 /*804858c:	55                   	push   %ebp
 804858d:	89 e5                	mov    %esp,%ebp
 804858f:	83 ec 28             	sub    $0x28,%esp
 8048592:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)*/
	int i = 0;

 /*8048599:	eb 4e                	jmp    80485e9 <sum_rows+0x5d>*/

 /*804859b:	c7 45 ec 00 00 00 00 	movl   $0x0,-0x14(%ebp)
 80485a2:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)*/
	int b = 0, c = 0;

 /*80485a9:	eb 1a                	jmp    80485c5 <sum_rows+0x39>

 80485ab:	8b 45 f4             	mov    -0xc(%ebp),%eax  // eax=i
 80485ae:	c1 e0 04             	shl    $0x4,%eax        // eax=i<<4
 80485b1:	89 c2                	mov    %eax,%edx        // edx=eax
 80485b3:	8b 45 08             	mov    0x8(%ebp),%eax   // eax=va
 80485b6:	01 c2                	add    %eax,%edx        // edx=va+i<<4
 80485b8:	8b 45 f0             	mov    -0x10(%ebp),%eax // eax=c
 80485bb:	8b 04 82             	mov    (%edx,%eax,4),%eax   // eax=va+i<<4+c<<2
 80485be:	01 45 ec             	add    %eax,-0x14(%ebp) // b=b+va+i<<4+c<<2
 80485c1:	83 45 f0 01          	addl   $0x1,-0x10(%ebp) // c+1
 80485c5:	83 7d f0 03          	cmpl   $0x3,-0x10(%ebp) // 3?=c
 80485c9:	7e e0                	jle    80485ab <sum_rows+0x1f>

 80485cb:	8b 45 ec             	mov    -0x14(%ebp),%eax // b
 80485ce:	89 44 24 08          	mov    %eax,0x8(%esp)   // (esp+8)=b
 80485d2:	8b 45 f4             	mov    -0xc(%ebp),%eax  // eax=i
 80485d5:	89 44 24 04          	mov    %eax,0x4(%esp)   // (esp+4)=i
 80485d9:	c7 04 24 5e 87 04 08 	movl   $0x804875e,(%esp)
 80485e0:	e8 ab fd ff ff       	call   8048390 <printf@plt>
 80485e5:	83 45 f4 01          	addl   $0x1,-0xc(%ebp)  // i+1
 80485e9:	8b 45 f4             	mov    -0xc(%ebp),%eax  // eax=i
 80485ec:	3b 45 0c             	cmp    0xc(%ebp),%eax   // vb?=i
 80485ef:	7c aa                	jl     804859b <sum_rows+0xf>*/
	for (i = 0; i < vb; i++) {
        b = 0;
        for (c = 0; c <= 3; c++) {
            b += va[i][c];    
        }  // - - -
		printf("%d %d\n", i, b);
	}

 /*80485f1:	c9                   	leave  
 80485f2:	c3                   	ret  */
}  

void sum_cols(int va[3][4], int vb)
{
 /*80485f3:	55                   	push   %ebp
 80485f4:	89 e5                	mov    %esp,%ebp
 80485f6:	83 ec 28             	sub    $0x28,%esp
 80485f9:	c7 45 f0 00 00 00 00 	movl   $0x0,-0x10(%ebp)*/
    int a = 0;

 /*8048600:	eb 50                	jmp    8048652 <sum_cols+0x5f>*/

 /*8048602:	c7 45 ec 00 00 00 00 	movl   $0x0,-0x14(%ebp)
 8048609:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)*/
    int b = 0, c = 0;

 /*8048610:	eb 1a                	jmp    804862c <sum_cols+0x39>

 8048612:	8b 45 f4             	mov    -0xc(%ebp),%eax  // eax=c
 8048615:	c1 e0 04             	shl    $0x4,%eax        // eax=c<<4
 8048618:	89 c2                	mov    %eax,%edx        // edx=eax
 804861a:	8b 45 08             	mov    0x8(%ebp),%eax   // eax=va
 804861d:	01 c2                	add    %eax,%edx        // edx=va+c<<4
 804861f:	8b 45 f0             	mov    -0x10(%ebp),%eax // eax=a
 8048622:	8b 04 82             	mov    (%edx,%eax,4),%eax   // eax=va+c<<4+a<<2
 8048625:	01 45 ec             	add    %eax,-0x14(%ebp) // b=b+va+c<<4+a<<2
 8048628:	83 45 f4 01          	addl   $0x1,-0xc(%ebp)  // c+1
 804862c:	8b 45 f4             	mov    -0xc(%ebp),%eax  // eax=c
 804862f:	3b 45 0c             	cmp    0xc(%ebp),%eax   // vb?=c
 8048632:	7c de                	jl     8048612 <sum_cols+0x1f>

 8048634:	8b 45 ec             	mov    -0x14(%ebp),%eax // b
 8048637:	89 44 24 08          	mov    %eax,0x8(%esp)
 804863b:	8b 45 f0             	mov    -0x10(%ebp),%eax // a
 804863e:	89 44 24 04          	mov    %eax,0x4(%esp)
 8048642:	c7 04 24 71 87 04 08 	movl   $0x8048771,(%esp)
 8048649:	e8 42 fd ff ff       	call   8048390 <printf@plt>
 804864e:	83 45 f0 01          	addl   $0x1,-0x10(%ebp) // a+1
 8048652:	83 7d f0 03          	cmpl   $0x3,-0x10(%ebp) // 3?=a
 8048656:	7e aa                	jle    8048602 <sum_cols+0xf>*/
    for (a = 0; a <=3 ; a++) {
        b = 0;
		for (c = 0; c < 3; c++) {
			b += va[c][a];
		}	// | | | |

		printf("%d %d\n", a, b);
	}

 /*8048658:	c9                   	leave  
 8048659:	c3                   	ret    */
}

int sum2d(int va[3][4], int vb)
{
 /*804865a:	55                   	push   %ebp
 804865b:	89 e5                	mov    %esp,%ebp
 804865d:	83 ec 10             	sub    $0x10,%esp
 8048660:	c7 45 f4 00 00 00 00 	movl   $0x0,-0xc(%ebp)
 8048667:	c7 45 fc 00 00 00 00 	movl   $0x0,-0x4(%ebp)*/
    int a = 0;
	int b = 0;

 /*804866e:	eb 2d                	jmp    804869d <sum2d+0x43>*/

 /*8048670:	c7 45 f8 00 00 00 00 	movl   $0x0,-0x8(%ebp)*/
    int c = 0;

 /*8048677:	eb 1a                	jmp    8048693 <sum2d+0x39>

 8048679:	8b 45 fc             	mov    -0x4(%ebp),%eax  // eax=b
 804867c:	c1 e0 04             	shl    $0x4,%eax        // eax=b<<4
 804867f:	89 c2                	mov    %eax,%edx        // edx=eax
 8048681:	8b 45 08             	mov    0x8(%ebp),%eax   // eax=va
 8048684:	01 c2                	add    %eax,%edx        // edx=va+b<<4
 8048686:	8b 45 f8             	mov    -0x8(%ebp),%eax  // eax=c
 8048689:	8b 04 82             	mov    (%edx,%eax,4),%eax   // eax=va+b<<4+c<<2
 804868c:	01 45 f4             	add    %eax,-0xc(%ebp)  // a=a+va+b<<4+c<<2
 804868f:	83 45 f8 01          	addl   $0x1,-0x8(%ebp)  // c+1
 8048693:	83 7d f8 03          	cmpl   $0x3,-0x8(%ebp)  // 3?=3
 8048697:	7e e0                	jle    8048679 <sum2d+0x1f>

 8048699:	83 45 fc 01          	addl   $0x1,-0x4(%ebp)  // b+1
 804869d:	8b 45 fc             	mov    -0x4(%ebp),%eax  // eax=b
 80486a0:	3b 45 0c             	cmp    0xc(%ebp),%eax   // vb?=b
 80486a3:	7c cb                	jl     8048670 <sum2d+0x16>*/
    for (b = 0; b < vb; b++) {
		for (c = 0; c <= 3; c++) {
			a += va[b][c];
		}
	}

 /*80486a5:	8b 45 f4             	mov    -0xc(%ebp),%eax
 80486a8:	c9                   	leave  
 80486a9:	c3                   	ret    
 80486aa:	66 90                	xchg   %ax,%ax
 80486ac:	66 90                	xchg   %ax,%ax
 80486ae:	66 90                	xchg   %ax,%ax*/
    return a;
}

